﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LogicalComponent.rules.grid
{
    /// <summary>
    /// Interface for a creator of tiles, this instance will do everythong necessary to
    /// instantiate a set of tiles for a grid.
    /// </summary>
    /// <typeparam name="T">  The type of tiles to create</typeparam>
    public abstract class TileFactory<T> where T : ITile
    {
        /// <summary>
        /// Makes the tile.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="z">The z.</param>
        /// <returns>The correct tile to place in the given x, z position.</returns>
        public abstract T MakeTile(int x, int z);

        List<List<T>> MakeAllTiles(int xSize, int zSize) 
        {
            List<List<T>> list = new List<List<T>>();
            for (int i = 0; i < xSize; i++)
            {
                List<T> innerList = new List<T>();
                for (int j = 0; j < zSize; j++)
                {
                    innerList.Add(this.MakeTile(i, j));
                }
                list.Add(innerList);
            }
            return list;
        }
    }
}
